<script setup>
import {ref} from "vue";
import axios from "axios";
import {ElMessage} from "element-plus";
import router from "@/router";

let user=ref({})
let login=()=>{
  axios.post("/api/auth/login/loginUser",user.value).then(
      res=>{
        if (res.data.code===200){
          let token=res.data.data.token
          sessionStorage.setItem("token",token)
          axios.defaults.headers.common.token=token
          ElMessage.success("登录成功")
          router.push("/activityList")
        }else {
          ElMessage.error(res.data.msg)
        }
      }
  )
}
</script>

<template>
用户名：<el-input v-model="user.username"></el-input>
密码：<el-input v-model="user.password"></el-input>
  <el-button type="primary" @click="login">登录</el-button>
</template>

<style scoped>

</style>